home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / D-G / FORTRAN Goodies / CallAd.txt < prev    next >
Encoding:
Text File  |  1992-11-03  |  677 b   |  43 lines  |  [TEXT/MPS ]

  1. c    CallAd.txt is an example of how to call a routine 
  2. c    by finding the address of any routine, passing the 
  3. c    address to a dispatch routine and calling the
  4. c    original routine using the passed address.
  5.  
  6. c    Example provided for owners of Language Systems FORTRAN
  7. c    © 1992 Language Systems Corp.
  8.     program Callit
  9.     
  10. 5    write(*,*) 'Enter a 1 or a 2:'
  11.     !Type Command-. to quit
  12.     Read(*,*) i
  13.     If (i .eq. 1) then
  14.         j = %loc(doOne)
  15.     else
  16.         j = %loc(doTwo)
  17.     end if
  18.  
  19.     Call Dispatch(%val(j))
  20.     go to 5
  21.     end
  22.     
  23.     Subroutine Dispatch(theProc)
  24.     External theProc
  25.     
  26.     Call theProc
  27.     return
  28.     end
  29.  
  30.  
  31.     Subroutine doOne
  32.     
  33.     write(*,*) 'One'
  34.     return
  35.     end
  36.     
  37.     Subroutine doTwo
  38.     
  39.     write(*,*) 'Two'
  40.     return
  41.     end
  42.     
  43.